package com.sunday.common.mq.rabbit.study.spring.study.e3_Receiving_Messages;

import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.amqp.rabbit.annotation.RabbitListenerConfigurer;
import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;

/**
 * https://docs.spring.io/spring-amqp/docs/current/reference/html/#rabbit-validation
 * @RabbitListener @Payload验证
 * 从版本 2.3.7 开始，现在可以更轻松地添加 a 以验证和参数。
 * 现在，您只需将验证器添加到注册商本身即可。Validator@RabbitListener@RabbitHandler@Payload
 */
@Configuration
@EnableRabbit
public class Config implements RabbitListenerConfigurer {

    @Autowired
    private LocalValidatorFactoryBean validator;

    @Override
    public void configureRabbitListeners(RabbitListenerEndpointRegistrar registrar) {
        registrar.setValidator(this.validator);
    }
}

